﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BlueLotus7
{
    partial class Validator
    {
        public static bool IsNullObject(object objectToCheck)
        {
            return objectToCheck == null;
        }

        public static bool IsNullOrWhiteSpaceString(string stringToCheck)
        {
            return string.IsNullOrWhiteSpace(stringToCheck);
        }

        public static void VerifyNullObject(object objectToCheck, string objectName)
        {
            if (IsNullObject(objectToCheck))
            {
                if (string.IsNullOrWhiteSpace(objectName))
                {
                    objectName = "[unknown]";
                }
                throw new NullReferenceException(objectName);
            }
        }

        public static void VerifyNullObject(object objectToCheck, Type type)
        {
            if (IsNullObject(objectToCheck))
            {
                throw new NullReferenceException(type.Name);
            }
        }

        public static void VerifyNullOrEmptyString(string stringToCheck, string stringName)
        {
            if (IsNullOrWhiteSpaceString(stringToCheck))
            {

                if (string.IsNullOrWhiteSpace(stringName))
                {
                    stringName = "[unknown]";
                }

                throw new NullOrEmptyStringException(stringName);
            }
        }
    }
}
